<template>
	<view class="">
		这是首页
		<h1>姓名：{{userInfo.name}}</h1>
		<h1>年龄：{{NewAge}}</h1>
		<button @click="changeName()">修改名称为：陈大狗</button>
	</view>
</template>

<script>
	// @ is an alias to /src
	// import HelloWorld from '@/components/HelloWorld.vue'
	import indexApi from '@/api/indexApi'

	export default {
		name: 'VueTest',
		components: {
			// HelloWorld
		},
		mounted() {
			// this.togetMenuOne()
		},
		computed:{
			name(){
				return this.$store.state.name
			},
			userInfo(){
				return this.$store.state.userInfo
			},
			NewAge(){
				return this.$store.getters.userInfoNewAge
			}
		},
		methods: {
			togetMenuOne() {
				indexApi.getMenuOne().then(res => {
					if (res.code == 1) {
						console.log(res);
					}
				})
			},
				changeName(){
					this.$store.dispatch('changeName','陈大狗')
					this.$store.commit('userInfo',{name:'陈大狗',age:21})
				}
		}
	}
</script>